package com.ruoyi.wq.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.wq.domain.WqDynamicTopic;
import com.ruoyi.wq.mapper.WqDynamicTopicMapper;
import com.ruoyi.wq.service.IWqDynamicTopicService;

/**
 * 动态主题Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-18
 */
@Service
public class WqDynamicTopicServiceImpl extends ServiceImpl<WqDynamicTopicMapper, WqDynamicTopic> implements IWqDynamicTopicService 
{
    @Autowired
    private WqDynamicTopicMapper wqDynamicTopicMapper;

    /**
     * 查询动态主题
     * 
     * @param id 动态主题主键
     * @return 动态主题
     */
    @Override
    public WqDynamicTopic selectWqDynamicTopicById(String id)
    {
        return wqDynamicTopicMapper.selectWqDynamicTopicById(id);
    }

    /**
     * 查询动态主题列表
     * 
     * @param wqDynamicTopic 动态主题
     * @return 动态主题
     */
    @Override
    public List<WqDynamicTopic> selectWqDynamicTopicList(WqDynamicTopic wqDynamicTopic)
    {
        return wqDynamicTopicMapper.selectWqDynamicTopicList(wqDynamicTopic);
    }

    /**
     * 新增动态主题
     * 
     * @param wqDynamicTopic 动态主题
     * @return 结果
     */
    @Override
    public int insertWqDynamicTopic(WqDynamicTopic wqDynamicTopic)
    {
        wqDynamicTopic.setCreateTime(DateUtils.getNowDate());
        return wqDynamicTopicMapper.insertWqDynamicTopic(wqDynamicTopic);
    }

    /**
     * 修改动态主题
     * 
     * @param wqDynamicTopic 动态主题
     * @return 结果
     */
    @Override
    public int updateWqDynamicTopic(WqDynamicTopic wqDynamicTopic)
    {
        wqDynamicTopic.setUpdateTime(DateUtils.getNowDate());
        return wqDynamicTopicMapper.updateWqDynamicTopic(wqDynamicTopic);
    }

    /**
     * 批量删除动态主题
     * 
     * @param ids 需要删除的动态主题主键
     * @return 结果
     */
    @Override
    public int deleteWqDynamicTopicByIds(String[] ids)
    {
        return wqDynamicTopicMapper.deleteWqDynamicTopicByIds(ids);
    }

    /**
     * 删除动态主题信息
     * 
     * @param id 动态主题主键
     * @return 结果
     */
    @Override
    public int deleteWqDynamicTopicById(String id)
    {
        return wqDynamicTopicMapper.deleteWqDynamicTopicById(id);
    }

	@Override
	public List<WqDynamicTopic> getTopicListByDynamicId(String dynamicId) {
		QueryWrapper<WqDynamicTopic> qw = new QueryWrapper<>();
		WqDynamicTopic dynamicTopic = new WqDynamicTopic();
		dynamicTopic.setDynamicId(dynamicId);
		qw.setEntity(dynamicTopic);
		return baseMapper.selectList(qw);
	}
}
